home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / demos / VisualAge for Java 2.0 Entry / setup / data1.cab / ide-e / IDE / cache / 1LKMKHU (.txt) < prev    next >
Encoding:
Java Class File  |  1998-09-16  |  2.0 KB  |  72 lines

  1. package java.awt;
  2.  
  3. import java.awt.image.ImageObserver;
  4. import java.io.Serializable;
  5.  
  6. class ImageMediaEntry extends MediaEntry implements ImageObserver, Serializable {
  7.    Image image;
  8.    int width;
  9.    int height;
  10.  
  11.    ImageMediaEntry(MediaTracker mt, Image img, int c, int w, int h) {
  12.       super(mt, c);
  13.       this.image = img;
  14.       this.width = w;
  15.       this.height = h;
  16.    }
  17.  
  18.    Object getMedia() {
  19.       return this.image;
  20.    }
  21.  
  22.    int getStatus(boolean doLoad, boolean doVerify) {
  23.       if (doVerify) {
  24.          int flags = super.tracker.target.checkImage(this.image, this.width, this.height, this);
  25.          int s = this.parseflags(flags);
  26.          if (s == 0) {
  27.             if ((super.status & 12) != 0) {
  28.                ((MediaEntry)this).setStatus(2);
  29.             }
  30.          } else if (s != super.status) {
  31.             ((MediaEntry)this).setStatus(s);
  32.          }
  33.       }
  34.  
  35.       return super.getStatus(doLoad, doVerify);
  36.    }
  37.  
  38.    public boolean imageUpdate(Image img, int infoflags, int x, int y, int w, int h) {
  39.       if (super.cancelled) {
  40.          return false;
  41.       } else {
  42.          int s = this.parseflags(infoflags);
  43.          if (s != 0 && s != super.status) {
  44.             ((MediaEntry)this).setStatus(s);
  45.          }
  46.  
  47.          return (super.status & 1) != 0;
  48.       }
  49.    }
  50.  
  51.    boolean matches(Image img, int w, int h) {
  52.       return this.image == img && this.width == w && this.height == h;
  53.    }
  54.  
  55.    int parseflags(int infoflags) {
  56.       if ((infoflags & 64) != 0) {
  57.          return 4;
  58.       } else if ((infoflags & 128) != 0) {
  59.          return 2;
  60.       } else {
  61.          return (infoflags & 48) != 0 ? 8 : 0;
  62.       }
  63.    }
  64.  
  65.    void startLoad() {
  66.       if (super.tracker.target.prepareImage(this.image, this.width, this.height, this)) {
  67.          ((MediaEntry)this).setStatus(8);
  68.       }
  69.  
  70.    }
  71. }
  72.